Skip to content

fix(fleet-proxy): bound connect_udp read_head_line accumulation during the read (#6511) - #6522

Merged
dezren39 merged 1 commit into
mainfrom
queue/11162-6511-connect-udp-head-bound
Nov 6, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/11162-6511-connect-udp-head-bound

Conversation

@dezren39

@dezren39 dezren39 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #6511

Problem

read_head_line in pkgs/fleet/crates/fleet-proxy/src/connect_udp.rs read a whole line into memory with read_until and only then checked the cumulative MAX_HEAD_BYTES (64 KiB) total — so one newline-free line accumulated without limit for as long as a peer kept sending, defeating the bound that exists so a peer cannot make the parser accumulate without limit.

Fix (route decided in triage task 11123)

Bound the read itself: read_head_line now wraps the reader in take(remaining + 1), where remaining = MAX_HEAD_BYTES - *total (the connect-udp bound is cumulative across the whole head, unlike http.rs's per-line cap in read_line_bounded, whose shape this mirrors). A line is refused with the existing InvalidData "request head exceeds the byte bound" error as soon as the cumulative total would cross MAX_HEAD_BYTES, without waiting for a newline; the +1 lets a line that exactly fills the remaining budget still succeed. The UdpProxyClient response-head reads reuse read_head_line and get the same fix for free.

No changes to session-count caps (#6152), capsule/datagram parsing, udp_forward.rs, or http.rs.

Tests

cargo test -p fleet-proxy on the laptop: 60 lib + 14 bin tests pass, including 4 new regression tests in connect_udp::tests:

  • head_line_bound_applies_during_the_read — a single over-bound newline-free line is refused with reader consumption and accounting both capped at bound + 1
  • head_line_bound_is_cumulative_across_lines — a second line gets only the remaining budget
  • head_line_exactly_at_the_bound_still_reads — a line exactly filling the budget succeeds; clean EOF at the bound is Ok(None)
  • request_head_over_bound_single_line_is_a_400 — the refusal surfaces as the existing 400 shape

cargo fmt -p fleet-proxy -- --check clean. (Laptop clippy is blocked by a pre-existing toolchain-version skew in the fleet-config build cache, unrelated to this change; CI clippy is authoritative.)

Queue: task 11162 (repo-health-code-pilot), lane code-v.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…g the read

read_head_line read a whole line into memory before checking the
cumulative MAX_HEAD_BYTES total, so one newline-free line accumulated
without limit (#6511). Bound the read itself with take(remaining + 1),
mirroring http.rs read_line_bounded but against the cumulative head
budget: a line is refused with the existing InvalidData error as soon
as the total would cross MAX_HEAD_BYTES, while a line exactly filling
the remaining budget still succeeds. The UdpProxyClient response-head
reads reuse read_head_line and get the same fix.

Regression tests pin: a single over-bound line is refused with
accumulation capped at bound+1, the bound is cumulative across lines,
a line exactly at the bound still reads with a clean EOF after it,
and read_request surfaces the refusal as a 400.
@dezren39
dezren39 requested a review from a team as a code owner November 6, 2026 13:40
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc821066-5ad1-48cd-94e5-029ba6091447
Commits

Reviewing files that changed from the base of the PR and between 6046e1d and a26f8cd.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-proxy/src/connect_udp.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T13:40:10.341030Z
We couldn’t complete this review. Comment @codex review to try again.
a26f8cd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fleet-proxy(connect-udp): request-head bound is checked only after a whole line arrives — one newline-free line accumulates without limit

1 participant